﻿// -----------------------------------------------------------------------
// <copyright file="Settings.cs" company="Abyssalsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Core.Player
{
    using System;
    using System.Collections.Generic;
    using System.Text;

    /// <summary>
    /// Contains methods of player configuration and settings
    /// </summary>
    public class Settings
    {
        /// <summary> Lock synchronization object. </summary>
        private static readonly object Padlock = new object();

        /// <summary> Stores current instance </summary>
        private static Settings instance = null;

        /// <summary> Equalizer back logic </summary>
        private Audio.Filters.AudioEqualizer equalizer;

        /// <summary> Prevents a default instance of the Settings class from being created. </summary>
        private Settings()
        {
            // Default, is stopped
            Status.PlaybackStatus = Status.StatusEnum.Stopped;
        }

        /// <summary> Gets the current instance of this class (Singleton - Thread safety)... With double check! </summary>
        public static Settings Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (Padlock)
                    {
                        if (instance == null)
                        {
                            instance = new Settings();
                        }
                    }
                }

                return instance;
            }
        }

        /// <summary>
        /// Gets or sets the Graphic equalizer style
        /// </summary>
        public int GraphicEqualizerStyle
        {
            get
            {
                return Audio.Filters.GraphicEqualizer.VisualisationStyle;
            }

            set
            {
                Audio.Filters.GraphicEqualizer.VisualisationStyle = value;
            }
        }

        /// <summary>
        /// Set equalizer value
        /// </summary>
        /// <param name="band">Band to modify</param>
        /// <param name="value">Value to set</param>
        public void SetEqualizer(int band, int value)
        {
            this.equalizer.SetEqualizer(band, value);
        }

        /// <summary>
        /// Initialize a new instance of the equalizer
        /// </summary>
        public void InitEqualizer()
        {
            this.equalizer = new Audio.Filters.AudioEqualizer();
        }
    }
}
